package com.igeek.boot.config;

import com.igeek.boot.entity.Address;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/8/13  16:47
 */
@Configuration
//开启配置绑定 开启address配置绑定的功能 把这个Address实例注册到ioc容器中
@EnableConfigurationProperties(Address.class)
public class MyConfig4 {

    //替换底层的multipartResolver --》 自制
    //其他组件会寻找MultipartResolver来使用
    @Bean
    public MultipartResolver multipart() {
        return new MultipartResolver() {
            @Override
            public boolean isMultipart(HttpServletRequest request) {
                return false;
            }

            @Override
            public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException {
                return null;
            }

            @Override
            public void cleanupMultipart(MultipartHttpServletRequest request) {

            }
        };
    }

}
